package com.woniuxy.service.impl;

import com.woniuxy.dao.RbacMenuDao;
import com.woniuxy.entity.RbacMenu;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 马宇航
 * @Todo: 菜单管理的业务层
 * @DateTime: 22/09/09/0009 11:11
 * @Component: 成都蜗牛学苑
 **/
@Service
public class RbacMenuServiceImpl implements RbacMenuService {
    @Autowired
    RbacMenuDao rbacMenuDao;
    @Override
    public ResponseEntity findAllMenu() {
        List<RbacMenu> rbacMenus = rbacMenuDao.findAll();
        return new ResponseEntity(rbacMenus);
    }

    @Override
    public ResponseEntity editOne(RbacMenu rbacMenu) {
        int i = rbacMenuDao.editOne(rbacMenu);
        if (i>0){
            return new ResponseEntity(200,"成功修改");
        }else {
            return new ResponseEntity(500,"修改失败");
        }
    }

    @Override
    public ResponseEntity updateMenu(int id, Integer fid) {
        if(fid == 0){
            fid = null;
        }
        int i = rbacMenuDao.updateMenu(id,fid);
        if (i>0){
            return new ResponseEntity(200,"成功修改");
        }else {
            return new ResponseEntity(500,"修改失败");
        }
    }
}
